

file9 = open(r"E:\project_python\NewN\NLP\col9.txt",'r',encoding="UTF-8") #20235行
file22 = open(r"E:\project_python\NewN\NLP\col22.txt",'r',encoding="UTF-8") #19889行
words = open(r"E:\project_python\NewN\NLP\words.txt",'r',encoding="UTF-8") # 782行\
fileright = open(r"E:\project_python\NewN\NLP\resfileright.txt",'w',encoding="UTF-8")

resfile = open(r"E:\project_python\NewN\NLP\resfile.txt",'w+',encoding='UTF-8')
listword = []
sentences = []

for word in words.readlines():
    word = word.strip()
    listword.append(word)
for lines in file9.readlines():
    lines = lines.strip()
    sentences.append(lines)
for line in file22.readlines():
    line = line.strip()
    sentences.append(line)

runList = []

indexList = []
# print("AnotherList的len是"+str(len(AnotherList)))
tenpercentnewList = [] #抽取百分之10

'''
def solveValueAnother():
    for index in indexList:
        print(index)
        AnotherList[index] = ""
    filter(None,AnotherList)
    for i in AnotherList:
        if i=="":
            AnotherList.pop()
    print("AnotherList的长度:"+str(len(AnotherList)))
    return AnotherList #合格AnotherList就是去掉空元素的
    #这里拿到的AnotherList就是去掉空元素 剩下的所有元素就是没有这些词对的
# solveValueAnother()
'''


def value():
    index = 0
    AnotherList = sentences.copy()
    for jword in listword:
        jword = jword.strip()
        # print(jword)
        for ksenten in sentences:
            if jword in str(ksenten):
                print("这是一个有词的句子,第index"+str(index)+"个 "+jword,sentences[index],file=resfile)
                # print(index)
                # print("Another移除了index"+str(index))
                list = [jword,ksenten.strip()]
                indexList.append(index)
                print(str(list),file=fileright)
                runList.append(list)
                print(index,file=fileright)
            index = index + 1
        index = 0
    filter(None,AnotherList)
    print(len(sentences))
    print(indexList)

    for index in indexList:
        print(index)
        AnotherList[index] = ""
    filter(None,AnotherList)
    for i in AnotherList:
        if i=="":
            AnotherList.pop()
    else:
        i = i.strip()
    print("AnotherList的长度:"+str(len(AnotherList)))
    print(len(indexList))
    resfile.close()
    return [runList,AnotherList]


